#ifndef GAMEINTERFACE_H
#define GAMEINTERFACE_H

#include <QMainWindow>
#include <QTimer>
#include <QTime>
#include <QPixmap>
#include <QPainter>
#include <QPaintEvent>
#include <QProcess>
#include <QCoreApplication>
#include <QDesktopWidget>
#include <QEventLoop>
#include"logical.h"
#include <QDebug>
#include <QLabel>
#include <QMouseEvent>
#include <QCloseEvent>
#include <QTextBrowser>
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlQuery>
#include "puase.h"
#include"database.h"
namespace Ui {
class GameInterface;
}

class GameInterface : public QMainWindow
{
    Q_OBJECT

public:
    explicit GameInterface(QWidget *parent = nullptr);
    ~GameInterface();
    void Game_start();
    QTimer *timer;
    Puase *p = new Puase();
    bool clicked = false;//用bool变量记录变换的次数
    bool pu = false;
    bool fob = false;
    string ID;//用户ID；
    QSqlDatabase db;
    QSqlQuery query;
private:
    QTimer m_Timer;
    Logical *gamelogic = new Logical();
    QPoint mouseSelection1;//鼠标位置
    QPoint mouseSelection2;
    QPoint mouseSelection3;
    QPixmap xxlPic[8];//存宝石图片
    QPixmap xxlPic2[8];
    QPixmap selectionBox;//储存被选中框
    QPixmap background;
    QPixmap background2;
    QPixmap explosionProcess1;
    QPixmap explosionProcess2;
    QPixmap explosionProcess3;//消除泡泡的过程

    int tips=5;
    bool first=false;
    bool second=false;
    bool third=false;
    int gemnums=5;
    int mouseflag;
    int mouseSelorder;
    int mouseSelX;//记录鼠标点击的xy
    int mouseSelY;
    int eliminateNumber = 0;//记录消除的数量--用于计分
    int choosen[8][8];//是否选中（0/1）
    int midBoomS[8][8];//消除中间过程（1，2，3，对应三张图片）
    string string_grade;//分数转成string类型
    int idGrade;//用户的分数
    int addScoreSituation=-1;//加分情况的状态（0-9）

private slots:
    void on_btn_Start_clicked();

    void on_btn_Tips_clicked();

    void on_btn_exit_clicked();

//    void on_pushButton_clicked();

    void paintEvent(QPaintEvent *event);//画被选中框，宝石图片，提示框，消除的中间过程，加分动画

    void closeEvent(QCloseEvent *event);//Game Over 函数

    void gameOVER();

    void subTime();

    void showTime(const unsigned int time_in_s);


    void on_pushButton_2_clicked();

private:
    Ui::GameInterface *ui;
    bool m_flag=false;

protected:
    void mousePressEvent(QMouseEvent *ev);
    int m_time = 120;//设定总时间
};

#endif // GAMEINTERFACE_H
